//
//  JSOrderListCell.m
//  jshop
//
//  Created by 张艳江 on 2019/5/21.
//  Copyright © 2019 张艳江. All rights reserved.
//

#import "SCOrderListCell.h"

@implementation SCOrderListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.goodsImage.contentMode = UIViewContentModeScaleAspectFill;
    self.goodsImage.clipsToBounds = YES;
}
- (void)setModel:(SCModel *)model{
    
    _model = model;
    if ([model.type intValue] == 1) {
        self.goodsPriceLab.text = [NSString stringWithFormat:@"%@福豆",model.payment_integral];
    }else if ([model.type intValue] == 2){
        self.goodsPriceLab.text = [NSString stringWithFormat:@"¥%@",model.price];
    }else if ([model.type intValue] == 3){
        self.goodsPriceLab.text = [NSString stringWithFormat:@"¥%@",model.payment_money];
    }
    [self.goodsImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",Goods_ImageURL,model.wap_pic]] placeholderImage:[UIImage imageNamed:@""]];
    self.goodsNameLab.text = model.gift_name;
    self.buyNumLab.text = [NSString stringWithFormat:@"x%@",model.num];
    if ([model.status intValue] == 1) {
        self.stateLab.text = @"待付款";
    }else if ([model.status intValue] == 2){
        self.stateLab.text = @"待发货";
    }else if ([model.status intValue] == 3){
        self.stateLab.text = @"待收货";
    }else if ([model.status intValue] == 4){
        self.stateLab.text = @"已签收";
    }else if ([model.status intValue] == 5){
        self.stateLab.text = @"交易成功";
    }else if ([model.status intValue] == 6){
        self.stateLab.text = @"退款失败";
    }else if ([model.status intValue] == 7){
        self.stateLab.text = @"待退货";
    }else if ([model.status intValue] == 8){
        self.stateLab.text = @"退款中";
    }else if ([model.status intValue] == 9){
        self.stateLab.text = @"退款成功";
    }else if ([model.status intValue] == 10){
        self.stateLab.text = @"交易关闭";
    }else if ([model.status intValue] == 11){
        self.stateLab.text = @"仅退款";
    }else if ([model.status intValue] == 12){
        self.stateLab.text = @"退款退货";
    }else if ([model.status intValue] == 13){
        self.stateLab.text = @"撤销申请";
    }else if ([model.status intValue] == 14){
        self.stateLab.text = @"商家等待收货";
    }
    self.confirmBtn.hidden = YES;
    self.refundBtn.hidden = YES;
}
- (void)setDetailModel:(SCModel *)detailModel{
    
    _detailModel = detailModel;
    
    if ([detailModel.type intValue] == 1) {
        self.goodsPriceLab.text = [NSString stringWithFormat:@"%@福豆",detailModel.payment_pure_integral];
    }else{
        self.goodsPriceLab.text = [NSString stringWithFormat:@"¥%@",detailModel.payment_pure_integral];
    }
    
    [self.goodsImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",Goods_ImageURL,detailModel.wap_pic]] placeholderImage:[UIImage imageNamed:@""]];
    self.goodsNameLab.text = detailModel.gift_name;
    self.buyNumLab.text = [NSString stringWithFormat:@"x%@",detailModel.num];
    self.stateLab.hidden = YES;
    if ([detailModel.status intValue] == 1 || [detailModel.status intValue] == 2) {
        self.confirmBtn.hidden = YES;
        [self.refundBtn setTitle:@"退款退货" forState:0];
    }else if ([detailModel.status intValue] == 3){
        self.confirmBtn.hidden = NO;
        [self.refundBtn setTitle:@"退款退货" forState:0];
    }else{
        self.confirmBtn.hidden = YES;
        self.refundBtn.hidden = YES;
    }
}
- (IBAction)clickBtns:(UIButton *)sender {
    
    if ([self.delegate respondsToSelector:@selector(clickCellButton:tag:)]) {
        [self.delegate clickCellButton:self.detailModel tag:sender.tag];
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}


@end
